//
//  LPUtils.h
//  LiePin
//
//  Created by apple on 13-12-5.
//  Copyright (c) 2013年 apple. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface LPUtils : NSObject

/** @brief Label设置 */
+ (void)initWihtLabel:(UILabel *)label color:(UIColor *)color fontSize:(float)size line:(int)line alignment:(NSTextAlignment)alignment;

/** @brief UITextField设置 */
+ (void)initWithTextField:(UITextField *)textField placeholder:(NSString *)placeholder textAlignment:(NSTextAlignment) textAlignment fontSzie:(float)fontSize textColor:(UIColor *)color;

+ (void) setButtonStyle:(UIButton *)button;

/** @brief 提示框 Alert */
+ (void)addAlert:(NSString*)alertTitle AlertMessage:(NSString*)alertMessage;

/** @brief 字符串编码 */
+ (NSString*) getEncodingWithUTF8 : (NSString*) str;

/** @brief 验证邮箱 */
+(BOOL)isValidateEmail:(NSString *)email;

/** @brief 判断有无特殊字符 */
+(BOOL)isValidateSpecialCode:(NSString *)str;

/** @brief	验证手机号码 */
+(BOOL)isValidatePhone:(NSString *)phone;

/** @brief	验证是否为数字 */
+(BOOL)isValidateNumber:(NSString *)number;

/** @brief	获得MD5字符串 */
+(NSString*)CCSMD5:(NSString*)str;

/** @brief 格式化日期 */
+ (NSString*)formatDate:(NSDate *)date withFormat:(NSString *)format;

+ (NSString *)getCurrentTime ;

/**
 * 计算指定时间与当前的时间差
 * @param compareDate   某一指定时间
 * @return 多少(秒or分or天or月or年)+前 (比如，3天前、10分钟前)
 */

+(NSString *) compareCurrentTime:(NSDate*) compareDate;

+ (NSString *) NSDateToNSString:(NSDate *)date;

/** @brief 删除Library/Cache下得缓存 */
+ (void)clearCache;

/** @brief 显示提示框 如同Toast一样 */
+(void)showTip:(NSString *)text inView:(UIView *)view;

/** @brief NSUserDefaults 存储数据*/
+(void)saveData:(id)value forKey:(NSString *)key;

/** @brief NSUserDefaults 获得数据*/
+(NSString *)getForKey:(NSString *)key;

/** @brief NSUserDefaults 删除数据*/
+(void)removeForKey:(NSString *)key;

/** @brief 获取字符串高度 */
+(CGFloat)getStringHight:(NSString*)input font:(UIFont*)font width:(CGFloat)width;

/** @brief 获取字符串宽度 */
+(CGFloat)getStringWidth:(NSString*)input font:(UIFont*)font;

/** @brief 获得工程下得Plist文件*/
+(NSDictionary *)getPlistData:(NSString *)name;

/** @brief 获得应用的版本*/
+(NSString *)getVersion;

/** @brief 获得应用的Bundle*/
+(NSString *)getBundle;

+(NSString *)documentPath:(NSString *)name;

+ (int)getStringLenghth:(NSString*)str;

+(UIView *)showPickerView:(id)delegate withTitle:(NSString *)title withAction:(SEL)action withTag:(NSInteger)tag;

+(UIView *)showView:(id)delegate withTitle:(NSString *)title withTitleArray:(NSArray *)array withAction:(SEL)action withTag:(NSInteger)tag;

+(UIView *)showDatePickerView:(id)delegate withTitle:(NSString *)title withAction:(SEL)action withTag:(NSInteger)tag;

+ (BOOL)checkEnableNet;

//+ (SIAlertView*)showLoading;
@end



CG_INLINE CGSize GTSizeMake(CGFloat width, CGFloat height) {
    CGSize size;
    float ratio = 1.0;
    if (iPhone5) {
        ratio = 0.853;
    } else if (iPhone6Plus) {
        ratio = 1.653;
    }
    
    size.width = width*ratio;
    size.height = height*ratio;
    
    return size;
}

CG_INLINE CGRect GTRectMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height) {
    float ratio = 1.0;
    if (iPhone5) {
        ratio = 0.853;
    } else if (iPhone6Plus) {
        ratio = 1.653;
    }
    
    CGRect rect;
    rect.origin.x = x*ratio;
    rect.origin.y = y*ratio;
    rect.size.width = width*ratio;
    rect.size.height = height*ratio;
    
    return rect;
}

CG_INLINE float GTFixWidth(CGFloat height) {
    float ratio = 1.0;
    if (iPhone5) {
        ratio = 0.853;
    } else if (iPhone6Plus) {
        ratio = 1.653;
    }
    
    return height*ratio;
}

CG_INLINE float GTFixHeight(CGFloat height) {
    float ratio = 1.0;
    if (iPhone5) {
        ratio = 0.853;
    } else if (iPhone6Plus) {
        ratio = 1.653;
    }
    
    return height*ratio;
}
